class CustomerRecordsController < ApplicationController
  layout "backend"
  def index
    @customer_records = CustomerRecord.find(:all)
  end
  def show
    @customer_record = CustomerRecord.find(params[:id])
  end
  def new
    @customer_record = CustomerRecord.new
  end
  def edit
    @customer_record = CustomerRecord.find(params[:id])
  end
  def create
    @customer_record = CustomerRecord.new(params[:customer_record])
    @customer_record.user_id = current_user.id
    if @customer_record.save
      flash[:notice] = 'Customer Record was successfully created.'
      redirect_to :controller => "repair_records", :action => "new", :customer_id => @customer_record.id
    else
      flash[:notice] = 'Customer Record failed to save.'
      redirect_to :action => "new"
    end
  end
  def update
    @customer_record = CustomerRecord.find(params[:id])
    if @customer_record.update_attributes(params[:customer_record])
      flash[:notice] = 'CustomerRecord was successfully updated.'
      redirect_to :controller => "customer_records"
    else
      flash[:notice] = 'Customer Record failed to update.'
      redirect_to :controller => "customer_records"
    end
  end
  def destroy
    @customer_record = CustomerRecord.find(params[:id])
    @customer_record.destroy
    redirect_to :controller => "customer_records"
  end
end
